<!--  -->
<template>
  <div class="bg-echart">
    <div
      ref="chart"
      style="width: 1000px; height: 400px; margin: 1rem 0; padding: 1rem"
    ></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "eChart",
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.renderChart();
  },
  methods: {
    renderChart() {
      const chartDom = this.$refs.chart;
      const myChart = echarts.init(chartDom);
      const options = {
        // ECharts的配置选项
        title: {
          text: "用户来源",
          textStyle: {
            color: '#6e7079' // 设置标题字体颜色
        }
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data: ["华东", "华南", "华西", "华北", "华中"],
          textStyle: {
            color: '#6e7079' // 设置图例字体颜色
        }
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: ["9-1", "9-2", "9-3", "9-4", "9-5", "9-6", "9-7"],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "华东",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "华南",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "华西",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "华北",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [320, 332, 301, 334, 390, 330, 320],
          },
          {
            name: "华中",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [820, 932, 901, 934, 1290, 1330, 1320],
          },
        ],
      };
      myChart.setOption(options);
    },
  },
};
</script>
<style scoped='less'>
.bg-echart {
  background-color: #f6f7f9;
  border-radius: 5px;
}
</style>